package com.yanqu.road.server.cmd.activity.feast;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ShanHeFeastProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.feast.ShanHeFeastModule;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.S_SHAN_HE_FEAST_BATTLE_SELECT_NPC, desc = "战斗事件选择对象")
public class FeastBattleNpcSelectCmd extends AbstractCommand {

	private Integer activityId;
	private int id;
	private int battleNum;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		ShanHeFeastProto.FeastBattleSelectNpcReqMsg reqMsg = ShanHeFeastProto.FeastBattleSelectNpcReqMsg.parseFrom(packet.getBytes());
		activityId = reqMsg.getActivityId();
		id = reqMsg.getId();
		battleNum = reqMsg.getBattleNum();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ret = player.getModule(ShanHeFeastModule.class).npcSelect(activityId, id, battleNum);
	}

	@Override
	public void sendData(GamePlayer player) {
		if(ret != 0){
			ShanHeFeastProto.FeastBattleSelectNpcRespMsg.Builder builder = ShanHeFeastProto.FeastBattleSelectNpcRespMsg.newBuilder();
			builder.setRet(ret);
			player.sendPacket(Protocol.U_SHAN_HE_FEAST_BATTLE_SELECT_NPC, builder);
		}
	}
}